.markdownWrapper {
  width: 100%;
  max-width: 100%;
  font-family: var(--main-font);
  font-size: var(--font-size-4);
  font-weight: 400;
  line-height: 1.8em;
  color: var(--global-body-text);
  word-break: break-word;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Exclude code blocks from text wrapping */
.markdownWrapper :global(pre),
.markdownWrapper :global(pre code),
.markdownWrapper :global(pre > div) {
  word-break: normal !important;
  word-wrap: normal !important;
  overflow-wrap: normal !important;
}

/* Headings */
.markdownWrapper :global(h1),
.markdownWrapper :global(h2),
.markdownWrapper :global(h3),
.markdownWrapper :global(h4),
.markdownWrapper :global(h5),
.markdownWrapper :global(h6) {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--global-body-text);
}

/* First element spacing adjustments */
.markdownWrapper :global(*:first-child) {
  margin-top: 0;
}

.markdownWrapper :global(h1) {
  padding-bottom: 0.3em;
  margin: 0.67em 0;
  font-size: 2em;
  font-weight: 600;
  border-bottom: 1px solid var(--global-border);
}

.markdownWrapper :global(h2) {
  padding-bottom: 0.3em;
  font-size: 1.5em;
  font-weight: 600;
  border-bottom: 1px solid var(--global-border);
}

.markdownWrapper :global(h3) {
  font-size: 1.25em;
  font-weight: 600;
}

.markdownWrapper :global(h4) {
  font-size: 1em;
  font-weight: 600;
}

.markdownWrapper :global(h5) {
  font-size: 0.875em;
  font-weight: 600;
}

.markdownWrapper :global(h6) {
  font-size: 0.85em;
  font-weight: 600;
}

/* Paragraphs */
.markdownWrapper :global(p) {
  margin-top: 0;
  margin-bottom: var(--spacing-2);
}

/* Lists */
.markdownWrapper :global(ul),
.markdownWrapper :global(ol) {
  padding-left: 2em;
  margin-top: 0;
  margin-bottom: var(--spacing-2);
}

.markdownWrapper :global(ul) {
  list-style-type: disc;
}

.markdownWrapper :global(ol) {
  list-style-type: decimal;
}

.markdownWrapper :global(ol ol),
.markdownWrapper :global(ul ol) {
  list-style-type: lower-roman;
}

.markdownWrapper :global(ul ul),
.markdownWrapper :global(ol ul) {
  list-style-type: circle;
}

.markdownWrapper :global(ul ul ul),
.markdownWrapper :global(ul ol ul),
.markdownWrapper :global(ol ul ul),
.markdownWrapper :global(ol ol ul) {
  list-style-type: square;
}

.markdownWrapper :global(ul ul ol),
.markdownWrapper :global(ul ol ol),
.markdownWrapper :global(ol ul ol),
.markdownWrapper :global(ol ol ol) {
  list-style-type: lower-alpha;
}

.markdownWrapper :global(li + li) {
  margin-top: 0.25em;
}

/* Code */
.markdownWrapper :global(code),
.markdownWrapper :global(tt) {
  padding: 0.2em 0.4em;
  margin: 0;
  font-family: var(--code-font);
  font-size: 85%;
  white-space: break-spaces;
}

/* Inline code within paragraphs and other elements */
.markdownWrapper :global(p > code),
.markdownWrapper :global(li > code),
.markdownWrapper :global(h1 > code),
.markdownWrapper :global(h2 > code),
.markdownWrapper :global(h3 > code),
.markdownWrapper :global(h4 > code),
.markdownWrapper :global(h5 > code),
.markdownWrapper :global(h6 > code),
.markdownWrapper :global(a > code),
.markdownWrapper :global(em > code),
.markdownWrapper :global(strong > code) {
  display: inline;
  padding: 0.1em 0.3em;
  font-family: var(--code-font, monospace);
  font-size: 85%;
  vertical-align: baseline;
  color: #e3e3e3;
  background-color: var(--overlay-10);
  border-radius: 3px;
}

.markdownWrapper :global(pre) {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin-bottom: var(--spacing-2);
  overflow-x: auto;
  border-radius: var(--border-radius-base);
}

/* Add a subtle scrollbar for code blocks that overflow */
.markdownWrapper :global(pre::-webkit-scrollbar) {
  height: var(--scrollbar-webkit-height);
  background-color: var(--scrollbar-track-background);
}

.markdownWrapper :global(pre::-webkit-scrollbar-thumb) {
  background-color: var(--scrollbar-thumb-background-hover);
  border-radius: var(--scrollbar-webkit-thumb-border-radius);
}

.markdownWrapper :global(pre::-webkit-scrollbar-track) {
  background-color: var(--scrollbar-track-background);
}

.markdownWrapper :global(pre code) {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  margin: 0;
  overflow: visible;
  font-size: 12px;
  line-height: inherit;
  word-break: normal !important;
  word-wrap: normal !important;
  white-space: pre !important;
  background-color: transparent;
  border: 0;
}

/* Ensure SyntaxHighlighter's container displays properly */
.markdownWrapper :global(pre > div) {
  overflow-x: auto !important;
  word-break: normal !important;
  word-wrap: normal !important;
  white-space: pre !important;
}

/* Links */
.markdownWrapper :global(a) {
  color: var(--primary-accent);
  text-decoration: none;
  background-color: transparent;
}

.markdownWrapper :global(a:hover) {
  text-decoration: underline;
}

/* Images */
.markdownWrapper :global(img) {
  box-sizing: content-box;
  max-width: 100%;
  border-style: none;
  border-radius: var(--border-radius-base);
}

/* Blockquotes */
.markdownWrapper :global(blockquote) {
  padding: 0 var(--spacing-2);
  margin: 0 0 var(--spacing-2) 0;
  border-left: 0.25em solid var(--global-border);
}

.markdownWrapper :global(blockquote) > :global(:first-child) {
  margin-top: 0;
}

.markdownWrapper :global(blockquote) > :global(:last-child) {
  margin-bottom: 0;
}

/* Tables */
.markdownWrapper :global(table) {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: var(--spacing-3);
  overflow-x: auto;
  border-spacing: 0;
  border-collapse: separate;
  border: 1px solid var(--global-border);
  border-radius: var(--border-radius-base);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Table scrollbar styling */
.markdownWrapper :global(table::-webkit-scrollbar) {
  height: var(--scrollbar-webkit-height);
  background-color: var(--scrollbar-track-background);
}

.markdownWrapper :global(table::-webkit-scrollbar-thumb) {
  background-color: var(--scrollbar-thumb-background-hover);
  border-radius: var(--scrollbar-webkit-thumb-border-radius);
}

.markdownWrapper :global(table::-webkit-scrollbar-track) {
  background-color: var(--scrollbar-track-background);
}

.markdownWrapper :global(table th) {
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
  color: var(--global-body-text);
  text-align: left;
  border-bottom: 2px solid var(--global-border);
}

.markdownWrapper :global(table th),
.markdownWrapper :global(table td) {
  padding: var(--spacing-1half) var(--spacing-2);
  border: 1px solid var(--global-border);
  border-top: none;
  border-left: none;
}

.markdownWrapper :global(table th:last-child),
.markdownWrapper :global(table td:last-child) {
  border-right: none;
}

.markdownWrapper :global(table tr:last-child td) {
  border-bottom: none;
}

/* Align numeric content to the right */
.markdownWrapper :global(table td:only-child),
.markdownWrapper :global(table td:first-child:last-child) {
  text-align: left;
}

.markdownWrapper :global(table td:not(:only-child)) {
  text-align: left;
}

/* Numeric content detection (approximate) */
.markdownWrapper :global(table td:not(:only-child):not(:first-child)) {
  text-align: right;
}

.markdownWrapper :global(table tr) {
  background-color: var(--global-background);
  transition: background-color 0.15s ease;
}

.markdownWrapper :global(table tr:nth-child(2n)) {
  background-color: rgba(var(--global-foreground-subtle-rgb, 0, 0, 0), 0.3);
}

.markdownWrapper :global(table tr:hover) {
  background-color: rgba(var(--primary-accent-rgb, 0, 0, 0), 0.05);
}

/* Task Lists */
.markdownWrapper :global(.task-list-item) {
  list-style-type: none;
}

.markdownWrapper :global(.task-list-item + .task-list-item) {
  margin-top: 0.25rem;
}

.markdownWrapper :global(.task-list-item-checkbox) {
  margin: 0 0.2em 0.25em -1.4em;
  vertical-align: middle;
}

/* Horizontal Rule */
.markdownWrapper :global(hr) {
  box-sizing: content-box;
  height: 0.25em;
  padding: 0;
  margin: var(--spacing-3) 0;
  overflow: hidden;
  background: transparent;
  background-color: var(--global-border);
  border: 0;
  border-bottom: 1px solid var(--global-border);
}

/* Emphasis */
.markdownWrapper :global(strong) {
  font-weight: 600;
}

.markdownWrapper :global(em) {
  font-style: italic;
}

/* Strikethrough */
.markdownWrapper :global(del) {
  text-decoration: line-through;
}

/* Definition Lists */
.markdownWrapper :global(dl) {
  padding: 0;
}

.markdownWrapper :global(dl dt) {
  padding: 0;
  margin-top: var(--spacing-2);
  font-size: 1em;
  font-style: italic;
  font-weight: 600;
}

.markdownWrapper :global(dl dd) {
  padding: 0 var(--spacing-2);
  margin-bottom: var(--spacing-2);
}

/* Special formatting for task list items */
.markdownWrapper :global(ul) :global(li.task-list-item) {
  padding-left: 0;
  list-style-type: none;
}

.markdownWrapper :global(ul) :global(li.task-list-item::before) {
  content: none;
}

/* Adjustments for GitHub Flavored Markdown */
.markdownWrapper :global(li:has(input[type='checkbox'])) {
  list-style-type: none;
}

.markdownWrapper :global(li:has(input[type='checkbox'])::before) {
  content: none;
}

.markdownWrapper :global(ul > li:has(input[type='checkbox'])) {
  position: relative;
  padding-left: var(--spacing-6);
}

.markdownWrapper :global(input[type='checkbox']) {
  position: absolute;
  top: 0.25em;
  left: 0;
  margin-right: 0.4em;
}
